#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int m = 0;
	int n = 0;
	scanf("%d %d", &m, &n);
	int arr1[1000];
	int arr2[1000];
	for (int k = 0; k < m; k++)
	{
		scanf("%d", &arr1[k]);
	}
	for (int k = 0; k < n; k++)
	{
		scanf("%d", &arr2[k]);
	}
	int i = 0;
	int j = 0;
	while(i<m&&j<n)
	{
		if (arr1[i] < arr2[j])
		{
			printf("%d ", arr1[i]);
			i++;
		}
		else
		{
			printf("%d ", arr2[j]);
			j++;
		}
	}
	if (j == n)
	{
		for (; i < m; i++)
		{
			printf("%d ", arr1[i]);
		}
	} 
	else
	{
		for (; j < n; j++)
		{
			printf("%d ", arr2[j]);
		}
	}
	
	return 0;
}